package net;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.socket.DatagramPacket;
import org.apache.log4j.Logger;

import java.util.Arrays;

public class UdpServerHandler  extends SimpleChannelInboundHandler<DatagramPacket> {

    private Logger logger = Logger.getLogger(UdpServerHandler.class);

    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, DatagramPacket datagramPacket)   {
        ByteBuf byt = datagramPacket.content();
        byte[] data = new byte[byt.readableBytes()];
        byt.readBytes(data);
        logger.info("length:" + data.length + ":" + Arrays.toString(data));
    }
}
